<?php

require_once 'Adapter/Svn.php';

class Skjb_VersionControl_Subversion_Repository
{
    protected $adapter = null;
    
    protected $url = null;
    
    protected $protocol = null;
    
    public $username = null;
    
    public $password = null;
    
    public function __construct($url)
    {
        $this->url = $url;
        
        if (!preg_match('/(http|https|svn|svn+ssh|file):\/\/(.+)/', $this->url, $matches)) {
            throw new Exception('Invalid Subversion URL: ' . $this->url);
        }
        
        $this->protocol = $matches[1];
        
        switch ($this->protocol) {
            case 'svn':
            	$this->adapter = new Skjb_VersionControl_Subversion_Adapter_Svn(array(
                    'url' => $this->url,
                ));
            	break;
            case 'http':
        	case 'https':
        	case 'svn+ssh':
        	case 'file':
            	throw new Exception('Unsupported Subversion protocol');
        }
    }
    
    public function checkout($path)
    {
        
    }
    
    public function setAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
        
        return $this;
    }
}